#!/bin/sh

if [[ -z $1 ]]; then
    TCASE="test_demo"
    COVER_OPT=""
    echo "default case: test_demo"
    echo "cover opt:none"${COVER_OPT}
elif [[ -z $2 ]]; then
    TCASE=$1
    COVER_OPT=""
    echo "run case: "${TCASE}
    echo "cover opt:"${COVER_OPT}
else
    TCASE=$1
    COVER_OPT="-cm line+cond+tgl+fsm+branch+assert"
    echo "run case: "$1 $2 
    echo "cover opt"${COVER_OPT}
fi
rm -rf ${TCASE}
mkdir ${TCASE}
cd ${TCASE}
cp ../../bench/tb_bench/tc/${TCASE}.v  ./testcase.v
cp ../../bench/tb_bench/tc/${TCASE}.ucli  ./testcase.ucli
echo "copy testcase name: ${TCASE}"

XX_LST="xx.lst"

#ONLY2018_VER1="-lmc-swift -kdb -vera"
ONLY2018_VER1="-cpp g++-4.8 -cc gcc-4.8 -LDFLAGS -Wl,--no-as-needed -lca -kdb"

vcs ${COVER_OPT} -debug_access+all -debug_pp -timescale=1ps/10fs -sverilog -debug_pp -Mupdate ${ONLY2018_VER1} +libext+.vlib+.v+.sv+.vp+.lib+v2k \
    -full64 +libverbose  +define+no_warning +nospecify +notimingcheck   -ntb_define NTB -ntb_opts rvm -ntb_opts use_sigprop -ntb_opts vera_compat -ntb \
    +lint=PCWM +lint=TFIPC-L +error+50 +define+RTL_SIM -f ../${XX_LST} -l vcs.log 

./simv ${COVER_OPT} +nowave +fsdb+force +testcase=${TCASE} -ucli -i ./testcase.ucli -l simv.log

cd -

#+++++++++++++++++++++++++ run history recorder +++++++++++++++++++++++++++++++++++++++++++
#current_time [clock format [clock seconds]]
current_time=$(date "+%Y-%m-%d %H:%M:%S")
eval exec echo "${current_time}: run ${TCASE}" >> run_history
